package com.nbsaas.boot.customer.rest.resource;

import com.nbsaas.boot.customer.api.apis.CustomerGroupApi;
import com.nbsaas.boot.customer.data.entity.CustomerGroup;
import com.nbsaas.boot.customer.api.domain.request.CustomerGroupRequest;
import com.nbsaas.boot.customer.api.domain.response.CustomerGroupResponse;
import com.nbsaas.boot.customer.api.domain.simple.CustomerGroupSimple;
import com.nbsaas.boot.customer.rest.convert.CustomerGroupSimpleConvert;
import com.nbsaas.boot.customer.rest.convert.CustomerGroupEntityConvert;
import com.nbsaas.boot.customer.rest.convert.CustomerGroupResponseConvert;
import com.nbsaas.boot.customer.data.repository.CustomerGroupRepository;

import java.io.Serializable;
import com.nbsaas.boot.jpa.data.core.BaseResource;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import org.springframework.data.jpa.repository.support.JpaRepositoryImplementation;

import java.util.function.Function;
/**
*   客户分组-业务接口实现
*/
@Transactional
@Service
public class CustomerGroupResource extends BaseResource<CustomerGroup,CustomerGroupResponse, CustomerGroupSimple, CustomerGroupRequest>  implements CustomerGroupApi {

    @Resource
    private CustomerGroupRepository customerGroupRepository;

    @Override
    public JpaRepositoryImplementation<CustomerGroup, Serializable> getJpaRepository() {
        return customerGroupRepository;
    }

    @Override
    public Function<CustomerGroup, CustomerGroupSimple> getConvertSimple() {
        return new CustomerGroupSimpleConvert();
    }

    @Override
    public Function<CustomerGroupRequest, CustomerGroup> getConvertForm() {
        return new CustomerGroupEntityConvert();
    }

    @Override
    public Function<CustomerGroup, CustomerGroupResponse> getConvertResponse() {
        return new CustomerGroupResponseConvert();
    }




}


